<?php
/**
 * 权限节点的管理
 */
namespace app\admin\controller;
use app\admin\model\AuthModel;
use think\Request;

class Auth extends Common
{
    protected function get_where()
    {
        $where = [];
        $key = Request::instance()->param('keyword');
        if($key != ''){
            $where['name'] = ['like','%'.$key.'%'];
        }
        return $where;
    }

    protected function add_assign()
    {
        $this->assign('auth_list',AuthModel::all(function($query){
            $query->where(['status'=>1,'is_menu'=>1]);
        }));
    }
    protected function update_assign()
    {
        $this->assign('auth_list',AuthModel::all(function($query){
            $id = Request::instance()->param('id');
            $where = [];
            $where['status'] = 1;
            $where['is_menu'] = 1;
            $where['id'] = ['neq',$id];
            $query->where($where);
        }));
    }
}
